import request from "@/utils/http"
import type { Cart, CartParams } from "@/types/Cart"


// 获取购物车数量
export const getCartCountApi = () => {
  return request<number>({
    url:'cart/front/count',
    method:"GET",
  })
}

// 购物车信息
export const getCartItemApi = () => {
  return request<Cart>({
    url:'cart/front/list',
    method:"GET"
  })
}

// 添加购物车
export const addCartApi = (data: CartParams) => {
  return request({
    url:`cart/front/add`,
    method:"POST",
    data,
  })
}

// 修改购物车
export const updateCartApi = (data: CartParams) => {
  return request({
    url:'cart/front/update',
    method:"PUT",
    data,
  })
}

// 删除购物车
export const deleteCartApi = (skuIds: number[]) => {
  return request({
    url:`cart/front/deletes`,
    method:"DELETE",
    data:skuIds,
  })
}

// 移入收藏
export const moveCollectApi = (data:{skuId: number, spuId:number}) => {
  return request({
    url:`cart/front/move/collect`,
    method:"POST",
    data,
  })
}

// 全选购物车
// 移入收藏
export const selectedAllApi = (selected: Boolean) => {
  return request({
    url:'cart/front/updates',
    method:"PUT",
    data:selected,
  })
}